<template>
  <div>
    <div class="header">
      <header class="header-inner w">
        <h1 @click="gohome">
          <a class="logo"></a>
        </h1>
        <div class="city-container" data-val="{currentcityid:55 }">
          <div class="city-selected">
            <div class="city-name">
              南京
              <span class="caret"></span>
            </div>
          </div>
        </div>
        <div class="nav">
          <ul class="navbar">
            <li>
              <a
                :class="{ active: '/home' === $route.path }"
                @click="$router.push('/home')"
                >首页</a
              >
            </li>
            <li>
              <a
                :class="{ active: '/film' === $route.path }"
                @click="$router.push('/film')"
                >电影</a
              >
            </li>
            <li>
              <a
                :class="{ active: '/cinema1' === $route.path }"
                @click="$router.push('/cinema1')"
                >影院</a
              >
            </li>
            <li>
              <a>演出</a>
            </li>
            <li>
              <a>榜单</a>
            </li>
            <li>
              <a>热点</a>
            </li>
            <li>
              <a>商城</a>
            </li>
          </ul>
        </div>
        <div class="userInfo">
          <div class="login">
            <img src="../assets/7d.png" alt="" />
            <span class="caret"></span>
            <ul class="user-menu no-login-menu">
              <li v-if="isshow"><a @click="gologin">登录</a></li>
            <li v-if="!isshow"><a>我的订单</a></li>
            <li v-if="!isshow"><a>我的基本信息</a></li>
              <li v-if="!isshow"><a @click="onLoginout">退出登录</a></li>
            </ul>
          </div>
        </div>
        <form
          action="/query"
          target="_blank"
          class="search-form"
          data-actform="search-click"
        >
          <input
            name="kw"
            class="search"
            type="search"
            maxlength="32"
            placeholder="找影视剧、影人、影院"
            autocomplete="off"
          />
          <div class="suggest-container" style="display:none">
            <div class="suggest-body">
              <span class="suggest-name">影人</span>
              <div class="suggest-detail-list">
                <a class="suggest-detail">
                  <img class="detail-img" src="" />
                  <span class="detail-name"></span>
                </a>
              </div>
            </div>
            <div class="suggest-body">
                <span class="suggest-name">影视剧</span>
              <div class="suggest-detail-list">
                <a class="suggest-detail">
                <img class="detail-img">
                <span class="detail-name"></span>
                </a>
              </div>
            </div>
          </div>
          <input class="submit" type="submit" value="" />
        </form>
        <div class="app-download">
          <a href="/app" target="_blank">
            <span class="iphone-icon"></span>
            <span class="apptext">APP下载</span>
            <span class="caret"></span>
            <div class="download-icon">
              <p class="down-title">扫码下载APP</p>
              <p class="down-content">选座更优惠</p>
            </div>
          </a>
        </div>
      </header>
    </div>
    <div class="header-placeholder"></div>
  </div>
</template>

<script>
export default {
  name: "Header",
  data() {
    return {
      isshow:true,
      userid:''
    };
  },
  created(){
    if(localStorage.getItem('token')){
      this.userid=localStorage.getItem('token')
      this.isshow=false
    }
  },
  methods: {
    gologin() {
      this.$router.push("/login");
    },
    gohome() {
      this.$router.push("/home");
    },
    onLoginout(){
      window.localStorage.token = ''
      // 刷新
      this.$router.go(0)
    },
  }
};
</script>
<style scoped>
.header {
  position: fixed;
  top: 0;
  z-index: 9999;
  width: 100%;
  min-width: 1200px;
  background-color: #fff;
  border-bottom: 1px solid #d8d8d8;
}
.header .logo,
.header a.logo {
  float: left;
  width: 133px;
  height: 80px;
}
.header-inner {
  height: 80px;
  line-height: 80px;
}
.logo {
  line-height: 80px;
  background: url(../assets/3.png) no-repeat 0;
  background-size: contain;
  overflow: hidden;
  cursor: pointer;
}
.city-container {
  position: relative;
  float: left;
  margin: 0 8px;
  height: 100%;
}
.city-selected {
  cursor: pointer;
  height: 100%;
  padding: 0 10px;
  border: 1px solid transparent;
  border-width: 0 1px;
  z-index: 101;
}
.city-name {
  display: inline-block;
  color: #333;
}
.city-name .caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 2px;
  vertical-align: middle;
  border-top: 5px solid #666;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  -webkit-transition: all 0.2s ease;
  transition: all 0.2s ease;
}
.nav {
  display: inline-block;
  background-color: #fff;
  overflow: hidden;
}
.navbar li {
  float: left;
}
.navbar li a {
  height: 80px;
  line-height: 80px;
  width: 70px;
  font-size: 18px;
  text-align: center;
  display: inline-block;
}
.navbar li a:hover {
  color: #ef4238;
}
.navbar li a.active {
  color: #fff;
  background-color: #ef4238;
}
.userInfo {
  float: right;
  z-index: 9999;
  height: 100%;
  position: relative;
}
.login {
  display: block;
  border: 1px solid transparent;
  border-top: none;
  border-bottom: none;
  padding: 0 10px;
  width: 56px;
  height: 100%;
}
.login img {
  margin-top: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
}
.login .caret {
  position: absolute;
  top: 39px;
  right: 10px;
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 2px;
  vertical-align: middle;
  border-top: 5px solid #666;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  -webkit-transition: all 0.2s;
  transition: all 0.2s;
}
.no-login-menu {
  padding: 15px 24px 5px;
}
.user-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 80px;
  border: 1px solid #d8d8d8;
  background-color: #fff;
  font-size: 14px;
  color: #333;
  text-align: right;
  padding: 15px 10px 5px;
  text-align: center;
}
.login:hover .user-menu {
  display: block;
}
.user-menu li {
  margin-bottom: 6px;
}
.user-menu li > a {
  color: #999;
  display: block;
  word-break: keep-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.search-form {
  float: right;
  margin: 0 10px 0 0;
  position: relative;
}
.search {
  display: inline-block;
  height: 40px;
  line-height: 80px;
  width: 220px;
  padding: 0 40px 0 20px;
  border: 1px solid #ccc;
  font-size: 14px;
  border-radius: 30px;
  background-color: #faf8fa;
  overflow: hidden;
  color: #333;
  list-style:none;
}
.search ~ .suggest-container {
  width: 240px;
  margin-top:-17px;
}
.suggest-container {
  border: 1px solid #ccc;
  margin-top: 1px;
  border-bottom: none;
  font-size: 14px;
  position: absolute;
  background-color: #fff;
  z-index: 999;
}
.suggest-body {
  border-bottom: 1px solid #ccc;
  float:left;
}
.suggest-name {
  display: inline-block;
  color: #999;
  width: 50px;
  margin-left: 10px;
  height: 68px;
  line-height: 68px;
  float: left;
}
.search ~ .suggest-container .suggest-detail-list {
  width: 180px;
}
.suggest-detail-list {
  float: left;
}
.suggest-detail:last-child {
  border: none;
}
.suggest-detail {
  border-bottom: 1px solid #e5e5e5;
  width: 100%;
  color: #333;
  display: block;
  text-decoration: none;
}
.detail-img {
  width: 36px;
  height: 50px;
  margin: 9px 10px 9px 0;
  float: left;
}
.search ~ .suggest-container .suggest-detail-list .detail-name {
  width: 134px;
}

.detail-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  height: 68px;
  line-height: 68px;
}
.search-form .submit {
  position: absolute;
  left: 181px;
  top: 22px;
  height: 38px;
  width: 38px;
  background-color: #ef4238;
  border-radius: 30px;
  background-color: #ef4238;
  background-image: url(../assets/4.png);
  cursor: pointer;
  border: 0;
}
.app-download {
  float: right;
  width: 132px;
  height: 80px;
  margin-right: 10px;
  position: relative;
}
.app-download a {
  float: left;
  display: block;
  padding-top: 0px;
  padding-left: 14px;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
}
.app-download a .iphone-icon {
  display: inline-block;
  width: 15px;
  height: 24px;
  background-image: url(../assets/5.png);
  background-size: cover;
  vertical-align: middle;
}
.app-download a .apptext {
  display: inline-block;
  font-size: 16px;
  color: #000;
  height: 24px;
  line-height: 24px;
  margin: 0 7px;
}
.app-download a .caret {
  display: inline-block;
  position: relative;
  top: -3px;
  width: 0;
  height: 0;
  margin-left: 2px;
  vertical-align: middle;
  border-top: 5px solid #666;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  -webkit-transition: all 0.2s ease;
  transition: all 0.2s ease;
}
.app-download a .download-icon {
  display: none;
  width: 130px;
  height: 165px;
  position: absolute;
  left: 0;
  top: 80px;
  background-color: #fff;
  background-image: url(../assets/6.png);
  background-position: 24px 24px;
  background-size: 82px 82px;
  background-repeat: no-repeat;
  border: 1px solid #dcd4d7;
  border-top: 0;
}
.down-title {
  margin-top: 115px;
  margin-bottom: 3px;
  color: #000;
  text-align: center;
  font-size: 14px;
  margin: 0;
}
.down-content {
  text-align: center;
  font-size: 14px;
  color: #999;
  margin: 0;
}
.header-placeholder {
  height: 81px;
}
</style>
